/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Componentes;

import Modelos.TblPantallas;
import Modelos.TblPantallasPerfiles;
import Modelos.TblPerfiles;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.TransferHandler;

/**
 *
 * @author luisramirezmartinez SAMI 2011
 *
 */
public class PantallasTransferHaandler extends TransferHandler {
    
    private tblDatos tblPerfil;
    private tblDatos tblPantalla;
    private List<TblPerfiles> ls;
    private List<TblPantallas> lsPantallas;
            
    public PantallasTransferHaandler(){

    }
    
     @Override
    public int getSourceActions(JComponent c) {
        // Sólo nos interesa mover
        return COPY;
    }

    @Override
    public boolean canImport(TransferSupport ts) {
        JTable.DropLocation dl =(JTable.DropLocation) ts.getDropLocation();
        if(dl.getRow()==-1)
            return false;
        return true;
    }

    @Override
    public boolean importData(TransferSupport ts) {
            if(!ts.isDrop()) return false;
            int row=tblPerfil.getSelectedRow()+1;
            int rowPantalla=tblPantalla.getSelectedRow()+1;
            TblPantallas p= lsPantallas.get(rowPantalla);
            //ls.get(row).getTblPantallasPerfilesCollection().add(new TblPantallasPerfiles(Boolean.FALSE, Boolean.FALSE, ls.get(row), p));
            ts.getComponent().repaint();
        return true;
    }


    public tblDatos getTblPerfil() {
        return tblPerfil;
    }

 
    public void setTblPerfil(tblDatos tblPerfil) {
        this.tblPerfil = tblPerfil;
    }

  
    public List<TblPerfiles> getLs() {
        return ls;
    }

    /**
     * @param ls the ls to set
     */
    public void setLs(List<TblPerfiles> ls) {
        this.ls = ls;
    }

    /**
     * @return the tblPantalla
     */
    public tblDatos getTblPantalla() {
        return tblPantalla;
    }

    /**
     * @param tblPantalla the tblPantalla to set
     */
    public void setTblPantalla(tblDatos tblPantalla) {
        this.tblPantalla = tblPantalla;
    }

    /**
     * @return the lsPantallas
     */
    public List<TblPantallas> getLsPantallas() {
        return lsPantallas;
    }

    /**
     * @param lsPantallas the lsPantallas to set
     */
    public void setLsPantallas(List<TblPantallas> lsPantallas) {
        this.lsPantallas = lsPantallas;
    }
    
    
    
    

}
